<%@ page language="java" contentType="text/html; charset=ISO-8859-1" import="java.sql.*,java.util.ArrayList,java.util.List,org.adg.code.model.NewReportReturn,org.adg.code.model.*;"
    pageEncoding="ISO-8859-1"%>
 <%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>ADG-Generate Report</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style2 {font-size: 52px; color: #333333; font-family: "Monotype Corsiva";}
#Layer1 {
	position:absolute;
	width:430px;
	height:29px;
	z-index:1;
	left: 196px;
	top: 94px;
}
.style4 {font-size: 22px; color: #333333; font-family: "Monotype Corsiva"; }
#Layer2 {
	position:absolute;
	width:124px;
	height:159px;
	z-index:1;
	left: 75px;
	top: 213px;
}
.style7 {font-size: 14px; color: #333333; }
.style8 {font-size: 20px}
#Layer3 {
	position:absolute;
	width:269px;
	height:32px;
	z-index:2;
	left: 4px;
	top: 126px;
}
.style9 {
	font-size: 25px;
	font-family: "Times New Roman", Times, serif;
	color: #000000;
}
#Layer4 {
	position:absolute;
	width:128px;
	height:34px;
	z-index:3;
	left: 1206px;
	top: 125px;
}
.style10 {font-size: 20px; font-family: "Times New Roman", Times, serif; color: #000000; }
#Layer5 {
	position:absolute;
	width:825px;
	height:34px;
	z-index:2;
	left: 27px;
	top: 129px;
}
#Layer6 {
	position:absolute;
	width:50%;
	height:81px;
	z-index:4;
	left: 25%;
	top: 215px;
}
body {
	font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif;
	font-size: .8em;
	}
 
/* the div that holds the date picker calendar */
.dpDiv {
	}
 
 
/* the table (within the div) that holds the date picker calendar */
.dpTable {
	font-family: Tahoma, Arial, Helvetica, sans-serif;
	font-size: 12px;
	text-align: center;
	color: #505050;
	background-color: #ece9d8;
	border: 1px solid #AAAAAA;
	}
 
 
/* a table row that holds date numbers (either blank or 1-31) */
.dpTR {
	}
 
 
/* the top table row that holds the month, year, and forward/backward buttons */
.dpTitleTR {
	}
 
 
/* the second table row, that holds the names of days of the week (Mo, Tu, We, etc.) */
.dpDayTR {
	}
 
 
/* the bottom table row, that has the "This Month" and "Close" buttons */
.dpTodayButtonTR {
	}
 
 
/* a table cell that holds a date number (either blank or 1-31) */
.dpTD {
	border: 1px solid #ece9d8;
	}
 
 
/* a table cell that holds a highlighted day (usually either today's date or the current date field value) */
.dpDayHighlightTD {
	background-color: #CCCCCC;
	border: 1px solid #AAAAAA;
	}
 
 
/* the date number table cell that the mouse pointer is currently over (you can use contrasting colors to make it apparent which cell is being hovered over) */
.dpTDHover {
	background-color: #aca998;
	border: 1px solid #888888;
	cursor: pointer;
	color: red;
	}
 
 
/* the table cell that holds the name of the month and the year */
.dpTitleTD {
	}
 
 
/* a table cell that holds one of the forward/backward buttons */
.dpButtonTD {
	}
 
 
/* the table cell that holds the "This Month" or "Close" button at the bottom */
.dpTodayButtonTD {
	}
 
 
/* a table cell that holds the names of days of the week (Mo, Tu, We, etc.) */
.dpDayTD {
	background-color: #CCCCCC;
	border: 1px solid #AAAAAA;
	color: white;
	}
 
 
/* additional style information for the text that indicates the month and year */
.dpTitleText {
	font-size: 12px;
	color: gray;
	font-weight: bold;
	}
 
 
/* additional style information for the cell that holds a highlighted day (usually either today's date or the current date field value) */ 
.dpDayHighlight {
	color: 4060ff;
	font-weight: bold;
	}
 
 
/* the forward/backward buttons at the top */
.dpButton {
	font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: gray;
	background: #d8e8ff;
	font-weight: bold;
	padding: 0px;
	}
 
 
/* the "This Month" and "Close" buttons at the bottom */
.dpTodayButton {
	font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: gray;
	background: #d8e8ff;
	font-weight: bold;
	}
.style1 {color: #000000;font-size: 16px;
	font-family: Georgia, "Times New Roman", Times, serif;
}
#Layer7 {
	position:absolute;
	width:586px;
	height:115px;
	z-index:5;
	left: 263px;
	top: 249px;
}
-->
</style>

<jsp:include page="../scripts/datepicker.jsp" />
</head>
<%ReportValues rv=(ReportValues)request.getAttribute("datavalues"); 
String reportname=rv.getReportname();
String username=rv.getUsername();
String reference=rv.getRef();
String ans=rv.getIsgenerated();
%>
<body onLoad="init();">
<jsp:include page="head.jsp" />
<Script Language="JavaScript">  
function init()
{
	document.getElementById("ruser").value="<%=username%>";
	
}
function setvalue(rval,hname)
{
var obj=document.getElementById(hname);
obj.value=rval;
}



function setcancel()
{
	document.getElementById("form2").action="adg.do?method=generatereport";
	document.getElementById("form2").submit();
}

function setparamdown()
{
	var ch=document.getElementById("isgenerated").value;
	
	if(ch=="yes")
	{
		document.getElementById("form2").action="adg.do?method=downloadreportfile";
		document.getElementById("form2").submit();
	}
	else
	{	alert("Unable to download report is not generated");
	return (false);
	}
		
}
function validate()
{
	var flag="0";
	var sel=document.getElementById("ruser");
	if(document.form1.rname.value =="")
   {
     alert("Please enter report name.");
     flag="1";
     document.form1.rname.select();
   return false;
   }
	else
	if ( sel.selectedIndex == 0 ) 
	{ 
		flag="1";
		alert ( "Please select Report User." ); 
		return false;
	}
	var nor=document.getElementById("numoffields").value;
	
	for(var k=1;k<nor+1;k++)
	{
		var fieldname="value"+k;
		if(document.getElementById(fieldname).value=="")
			{
			
			alert("Values shiuld be entered for all the fields");
			return false;
			}
	}
	return true;
}

</Script>  

<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<%String rn=(String)request.getAttribute("rn"); %>
<div id="Layer6">
  <form name="form1" id="form1" method="post" action="adg.do?method=generatereportfile" onsubmit="return validate()">
     <input type="hidden" id="rcatname" name="rcatname" value="<%=rn%>"/>
   
    <div align="center" class="style1">Report Catagory : <%=rn%>
     &nbsp;
      
    </div>
    
    <table width="484" border="0" align="center" cellpadding="2" cellspacing="3">
    <tr>
      <td width="225" bgcolor="#FFFFFF" class="style1"><div align="right"> Report Name :</div></td>
      <td width="312" bgcolor="#FFFFFF"><div align="left">
        <input type="text" id="rname" name="rname" readonly value="<%=reportname %>"/>*
      </div></td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" class="style1"><div align="right">Report User :</div></td>
      <td bgcolor="#FFFFFF"><div align="left">
        <label for="select"></label>
      </div>
          <label for="select"></label>
          <div align="left">
            <select name="ruser" id="ruser">
              <option>---select---</option>
              <% 
	
		ResultSet resultSet = (ResultSet)request.getAttribute("unames");
		while(resultSet.next())
		{
			String uname=resultSet.getString(1);

%>
			<option value="<%=uname%>"><%=uname%></option>
<%
		}
	
%>
                    </select>*
        </div></td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" class="style1"><div align="right">Reference :</div></td>
      <td bgcolor="#FFFFFF"><div align="left">
        <input type="text" id="ref" name="ref" value="<%=reference%>"/>
      </div></td>
    </tr>
  </table>
    
    <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
    
    <table id="multipleRangeTable" width="484" height="30" border="0" align="center" cellpadding="2" cellspacing="3">
      
      <%
      
      NewReportReturn nrr=(NewReportReturn)request.getAttribute("nrr");
      ArrayList rptname=nrr.getRptName();
      ArrayList uitypes=nrr.getuitype();
      ArrayList rpt=nrr.getrptid();
      TemplateMultiValues[] tmv=nrr.getTmv();
      
      int len=uitypes.size();
      String n="value";
      String lb="label";String s="";String rid="";String nm="";
      int r=0;
      
      	
      ResultSet rs=rv.getRs();
      String dval="";
      for(int i=0,j=1;i<len;i++,j++)
      { 	n="value";lb="label";
      n=n+j;lb=lb+j; 
      s=(String)uitypes.get(i);
      rid=(String)rpt.get(i);
 //     r=Integer.parseInt();
      nm=(String)rptname.get(i);
      if(rs.next())
      {
    	  dval=(String)rs.getString(1);
      }
      %>
      <tr>
      <td width="225" class="style1"><input type="hidden" id="<%=lb%>" name="<%=lb%>" value="<%=rid%>"/><div align="right"><%=nm%> : </div></td>
        <td width="312"><div align="left"><%if(s.equalsIgnoreCase("textbox")){ %> 
         <input type="text" id="<%=n%>" name="<%=n%>" value="<%=dval%>"/>
         <%}
         else if(s.equalsIgnoreCase("password")){%>
         <input type="password" id="<%=n%>" name="<%=n%>" value="<%=dval%>"/>
         <%}
         else if(s.equalsIgnoreCase("textarea")){%>
         <textarea id="<%=n%>" name="<%=n%>"><%=dval%></textarea>
         <%}
         else if(s.equalsIgnoreCase("date")){%>
         <input type="text" id="<%=n%>" name="<%=n%>" value="<%=dval%>"/>
         <IMG src="images/cal.gif" height=18 width=18 border=0 alt="Calendar" onClick="javascript:displayDatePicker('<%=n%>',this);">  
          <%}
         else if(s.equalsIgnoreCase("Selectbox")){%>
         <select id="<%=n%>" name="<%=n%>">
          <option value="<%=dval%>"><%=dval%></option>
          <% 
		List ls=tmv[i].getList();
		
		for(int k=0;k<ls.size();k++)
		{
			String val=(String)ls.get(k);
		
		%>
			<option value="<%=val%>"><%=val%></option>
		<%}%>
		</select>
	    <%}
	    else if(s.equalsIgnoreCase("Radiobutton")){%>
	    	<input type="hidden" id="<%=n%>" name="<%=n%>" value="<%=dval%>"/>
	   <% List ls=tmv[i].getList();
		String radioname="group1"+i+j;
		for(int k=0;k<ls.size();k++)
		{
			String val1=(String)ls.get(k);
			
		if(val1.equalsIgnoreCase(dval)){%>
	    <input type="radio" checked name="<%=radioname%>" value="<%=val1%>" onClick="setvalue('<%=val1%>','<%=n%>')"><%=val1 %><br>
	    <%}else{%>
	        <input type="radio" name="<%=radioname%>" value="<%=val1%>" onClick="setvalue('<%=val1%>','<%=n%>')"><%=val1 %><br>       
         <%}}}%>
        </div></td> 
      </tr>
      <%}%>
    </table>
    <input type="hidden" id="numoffields" name="numoffields" value="<%=len %>"/>
   <div align="center">
    <input type="submit" name="generate" class="button" value="Generate"/>
       <input type="button" name="download" class="button" value="download" onClick="return setparamdown()"/>
       <input type="button" name="cancel" value="cancel" class="button" onClick="setcancel()" />
        </div>
     </form>
    <p>&nbsp;</p>
 
  
       
      <form name="form2" id="form2" method="post" action="" >
        <input type="hidden" id="isgenerated" name="isgenerated" value="<%=ans%>"/>
         <input type="hidden" id="reportname" name="reportname" value="<%=reportname %>"/>
        
   </form>
 
  
  

  
  

 
  

</div>

<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><br />
</p>

 
<form id="linkform" name="linkform" method="post" action="">
 
</form>
</body>
</html>
